﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace eTerm.NetSocket
{
        #region 转发服务器
    public sealed class eTermAPIServer : TSocketServerBase<eTermAPISession, eTermDatabase>
        {
            #region 定量定义
            private static object m_syncObj = new object();
            #endregion

            #region 服务开启
            /// <summary>
            /// 开启服务侦听.
            /// </summary>
            /// <returns></returns>
            public override bool Start()
            {
                //if (manager.IsValid && manager.SetupBin.AllowAPI)
                //    return base.Start(manager);
                return false;
            }
            #endregion

            #region 构造函数
            /// <summary>
            /// Initializes a new instance of the <see cref="eTermTransferServer"/> class.
            /// </summary>
            public eTermAPIServer()
                : this(350)
            {

            }

            /// <summary>
            /// Initializes a new instance of the <see cref="eTermTransferServer"/> class.
            /// </summary>
            public eTermAPIServer(int port)
                : base(port, string.Empty)
            {
            }
            #endregion

            #region 重写
            /// <summary>
            /// Called when [session disconnected].
            /// </summary>
            /// <param name="session">The session.</param>
            protected override void OnSessionDisconnected(eTermAPISession session)
            {
                base.OnSessionDisconnected(session);
                if (session.eTermSession == null) return;
                session.eTermSession.TSession = null;
                if (session.eTermSession != null)
                    session.eTermSession.SendStream(@"IG");
                session.eTermSession = null;
            }
            #endregion
        }
        #endregion

}
